<script setup lang="ts">
import { computed } from 'vue'
import { RouterView } from 'vue-router'

import { ConfigStore } from '@/stores/modules/config'

import zhCn from 'element-plus/es/locale/lang/zh-cn'
import en from 'element-plus/es/locale/lang/en'

const configState = ConfigStore()

const themeConfig = computed(() => configState.themeConfig)

const locale = computed(() => {
  switch (configState.language) {
    case 'en':
      return en
    case 'zh-cn':
      return zhCn
    default:
      return zhCn
  }
})
</script>

<template>
  <el-config-provider :locale="locale" :size="themeConfig.size">
    <router-view v-slot="{ Component }">
      <keep-alive>
        <component :is="Component"></component>
      </keep-alive>
    </router-view>
  </el-config-provider>
</template>
